{extend name="layout_modal" /}
{block name="content"}
<section class="content" style="padding-top:0;padding-bottom: 0">
<div class="row" style="padding-bottom: 0">
  <div class="box" style="margin-bottom: 0">
    <div class="box-header with-border">
      <h3 class="box-title"><i class="fa fa-building-o"></i> 选择经销商</h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
      <form role="form" action="{:url('set_dealer')}">
      <table class="layui-table" lay-even>
        <colgroup>
          <col width="35">
          <col width="30">
        </colgroup>
        <thead>
        <tr>
            <th><input type="checkbox" id="check_all" /></th>
            <th>ID</th>
            <th>全称</th>
            <th>简称</th>
            <th>省份</th>
            <th>城市</th>
            <th>用户类型</th>
            <th>状态</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="v"}
        <tr>
            <td><input type="checkbox" value="{$v.userid}" name="dealer_ids[]" class="dealer_check" {eq name=":in_array($v.userid, $dealer_list)" value="true"} checked {/eq}></td>
            <td>{$v.userid}</td>
            <td>{$v.fullname}</td>
            <td>{$v.realname}</td>
            <td>{$v.province}</td>
            <td>{$v.city}</td>
            <td>{$v.roleName}</td>
            <td>{$v.statusname}</td>
        </tr>
        {/volist}
        </tbody>
      </table>
      <input type="hidden" name="id" value="{$id}">
      </form>
    </div>
    <!-- /.box-body -->
    <!-- <div id="pages" class="box-footer clearfix pages" style="text-align: center;padding:0"></div> -->
  </div>
</div>
</section>
{/block}
{block name="script"}
<script type="text/javascript">
  $(document).ready(function() {
    $('#check_all').click(function(item) {
      if ($('#check_all').is(':checked')) {
        $('.dealer_check').each(function() {
          $(this).prop('checked', true);
        });
      }else{
        $('.dealer_check').each(function () {
          $(this).prop('checked',false);
        });
      }
    });
  });
</script>
{/block}